package com.smarthome.core.propertymanager.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.smarthome.base.service.ShServiceService;
import com.smarthome.core.messageTask.MessageTaskService;
import com.smarthome.core.propertymanager.PropertyServiceService;
import com.smarthome.domain.bean.ShService;
import com.smarthome.domain.enums.ServiceStatusEnum;
import com.smarthome.domain.vo.boss.DataGrid;
import com.smarthome.domain.vo.boss.PageHelper;
import com.smarthome.domain.vo.boss.TaskMessageVo;

@Service("propertyServiceService")
public class PropertyServiceServiceImpl implements PropertyServiceService, MessageTaskService {

	@Resource
	private ShServiceService shServiceService;

	@Override
	public DataGrid dataGrid(PageHelper page, ShService service) {
		return shServiceService.queryShServices(page, service);
	}

	@Override
	public ShService queryPropertyServiceById(Long serviceId) {
		return shServiceService.selectEntryById(serviceId);
	}

	@Override
	public void saveOrEdit(ShService service) {
		shServiceService.saveOrUpdate(service);
	}

	@Override
	public List<ShService> getPropertyServiceList(ShService service) {
		return shServiceService.getPropertyServiceList(service);
	}

	@Override
	public int insert(ShService service) {
		return shServiceService.insert(service);
	}

	@Override
	public int count(ShService service) {
		return shServiceService.count(service);
	}

	@Override
	public TaskMessageVo getTaskMessage(Long residenceId) {
		TaskMessageVo vo = new TaskMessageVo();
		vo.setMessageType(TaskMessageVo.TaskMessageType.PROPERTYSERVICE);
		ShService service = new ShService();
		service.setResidenceId(residenceId);
		service.setStatus(ServiceStatusEnum.APPLICATION.getCode());
		vo.setCount(shServiceService.queryServiceCount(service));
		vo.setParam("status=0");
		return vo;
	}

}
